//SPDX-FileCopyrightText: Copyright 2022-2024 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

package main

import (
	"encoding/json"
	"fmt"
	"os"

	"atomgit.com/openlinksaas/search-proxy/core"
	"atomgit.com/openlinksaas/search-proxy/impl"
)

func main() {
	if len(os.Args) != 2 {
		fmt.Println("[]")
		return
	}
	entryList, err := impl.Search(os.Args[1])
	if err != nil {
		os.Stderr.WriteString(err.Error())
		entryList = []*core.SearchEntry{}
	}
	jsonData, err := json.Marshal(entryList)
	if err != nil {
		os.Stderr.WriteString(err.Error())
	}
	fmt.Println(string(jsonData))
}
